Skip to content

sdmx: add minimal ISTAT endpoint fallback#76

Merged
Gabrymi93 merged 2 commits intomainfrom
feat/sdmx-istat-endpoint-fallback
Mar 31, 2026
Merged

sdmx: add minimal ISTAT endpoint fallback#76
Gabrymi93 merged 2 commits intomainfrom
feat/sdmx-istat-endpoint-fallback

Conversation

@Gabrymi93
Copy link
Copy Markdown
Member

Closes #75.

Contesto

Il primo pilot reale SDMX su istat-housing-crowding ha mostrato che il plugin sdmx regge sul caso stretto, ma resta fragile quando gli endpoint ISTAT si comportano in modo incoerente tra metadata e data.

Cosa cambia

  • aggiunge un fallback minimo tra i due endpoint ISTAT per agency=IT1
  • il fallback si attiva solo su:
    • timeout / connect timeout
    • errori 5xx
  • non si attiva su 404, che resta trattato come query/filtro non supportato
  • migliora i messaggi di errore per distinguere meglio:
    • timeout endpoint
    • 5xx lato fonte
    • 404 query non trovata

Test

Aggiunti test per:

  • metadata endpoint A fail -> fallback endpoint B
  • data endpoint A fail -> fallback endpoint B
  • 404 non deve attivare fallback

Test eseguiti:

  • tests/test_sdmx_plugin.py
  • tests/test_ckan_plugin.py
  • tests/test_raw_ext_inference.py
  • tests/test_registry.py

Totale locale: 24 passed

Note

Questo PR non introduce caching, backoff sofisticato o failover complesso.
Punta solo a un hardening minimo e difendibile del plugin SDMX contro l'instabilita' degli endpoint ISTAT.

@Gabrymi93 Gabrymi93 marked this pull request as ready for review March 31, 2026 17:17
@Gabrymi93
Copy link
Copy Markdown
Member Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 918732d3da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Gabrymi93
Copy link
Copy Markdown
Member Author

Findings

Medium

  • toolkit/plugins/sdmx.py: La classificazione dell'errore in _is_retryable_fallback_error si basa sul matching di stringhe prodotte nella stessa classe (_get_text). Sebbene coerente internamente, rende il meccanismo di fallback dipendente dalla forma letterale dei messaggi d'errore.

Low

  • toolkit/plugins/sdmx.py: Le eccezioni di tipo ConnectionError vengono catalogate come "timeout" nel messaggio d'errore. Sebbene il fallback scatti correttamente (che è l'obiettivo), il messaggio potrebbe essere leggermente più preciso (es. "connection error or timeout").
  • toolkit/plugins/sdmx.py: Gli URL ISTAT sono hardcoded come costanti. È una scelta accettabile per un hardening mirato su ISTAT, ma potrebbe essere utile in futuro spostarli in una configurazione o nel registry se ISTAT dovesse cambiare spesso le rotte.

Open questions

  • Gli URL scelti (sdmx.istat.it e esploradati.istat.it) coprono la quasi totalità dei casi ISTAT attuali. Esistono casi noti in cui agency=IT1 richiede endpoint diversi? (Al momento non risultano dai pilot).

Verdict

Tip

Verdict: merge

Il PR è solido, ben testato e risponde esattamente al problema di affidabilità sollevato in #75 senza sovradimensionare la soluzione tecnica. I test mock coprono i casi limite (timeout, 5xx, 404) in modo efficace.


Review effettuata seguendo la skill canonica review-pr (lab-ops v1.1).

@Gabrymi93 Gabrymi93 merged commit 944fdea into main Mar 31, 2026
5 checks passed
@Gabrymi93 Gabrymi93 deleted the feat/sdmx-istat-endpoint-fallback branch March 31, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sdmx: add minimal ISTAT endpoint fallback and clearer error classification

1 participant